home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / ShellTool.C < prev    next >
C/C++ Source or Header  |  1992-08-10  |  2KB  |  94 lines

  1. #ifdef __GNUG__
  2. #pragma implementation
  3. #endif
  4.  
  5. #include "ShellTool.h"
  6.  
  7. #include "Class.h"
  8. #include "Window.h"
  9. #include "Scroller.h"
  10. #include "ShellTView.h"
  11. #include "CommandProcessor.h"
  12. #include "StyledText.h"
  13. #include "MenuBar.h"
  14. #include "Menu.h"
  15. #include "Env.h"
  16.  
  17. const int cSHOWERR      =   cUSERCMD + 2;
  18.  
  19.  //---- ShellTool -----------------------------------------------------------
  20.  
  21. NewMetaImpl(ShellTool, Manager, (TP(view), TP(text), T(cnt)));
  22.  
  23. int ShellTool::shellcnt;
  24.  
  25. ShellTool::ShellTool() : Manager()
  26. {
  27.     cnt= ShellTool::shellcnt++;
  28.     fd= gFixedFont;
  29.     if (Env::GetValue("ShellText.UseStyles", TRUE))
  30.     text= new StyledText(256, fd);
  31.     else
  32.     text= new GapText(256, fd);
  33. }
  34.  
  35. ShellTool::~ShellTool()
  36. {
  37.     SafeDelete(view); 
  38.     SafeDelete(text);
  39. }
  40.  
  41. VObject *ShellTool::DoMakeContent()
  42. {   
  43.     static char *argv[2];
  44.  
  45.     argv[0]= Env::GetValue("SHELL", "/bin/csh");
  46.     view= new ShellTextView(this, Rectangle(Point(1000,cFit)), text, argv[0], argv);
  47.     Scroller *shScroller= new Scroller(view, Point(300, 200), cIdNone, eScrollRight);
  48.     shClipper= shScroller->GetClipper();
  49.     shClipper->SetFlag(eVObjLayoutCntl);
  50.     SetFirstHandler(view);
  51.     return shScroller;
  52. }
  53.  
  54. Point ShellTool::GetInitialWindowSize()
  55. {
  56.     return Point(650, 440);
  57. }
  58.  
  59. void ShellTool::Control(int id, int detail, void *data)
  60. {
  61.     if (detail == cPartExtentChanged && data == (void*) shClipper) 
  62.     view->ChangedViewRect(shClipper->ContentRect());
  63.     else
  64.     Manager::Control(id, detail, data);
  65. }
  66.  
  67. MenuBar *ShellTool::DoMakeMenuBar()
  68. {
  69.     MenuBar *mb= new MenuBar;
  70.     
  71.     mb->AddMenu(MakeMenu(cHELPMENU));
  72.     mb->AddMenu(MakeMenu(cMANAGERMENU));
  73.     mb->AddMenu(MakeMenu(cEDITMENU));
  74.     Menu *m= ShellTextView::MakeMenu(cSHELLMENU);
  75.     m->AppendItem("Show Error@E", cSHOWERR);
  76.     mb->AddMenu(m);
  77.     return mb;
  78. }
  79.  
  80. void ShellTool::DoSetupMenu(Menu *m)
  81. {
  82.     Manager::DoSetupMenu(m);
  83.     m->EnableItem(cSHOWERR);
  84. }
  85.  
  86. void ShellTool::ShellExecute(char *cmd)
  87. {
  88.     if (view) {
  89.     view->Submit(cmd, strlen(cmd));
  90.     view->SetSelection(text->Size(), text->Size());
  91.     }
  92. }
  93.  
  94.